/*
 * @Author: your name
 * @Date: 2021-01-22 10:57:04
 * @LastEditTime: 2021-02-25 14:30:49
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \water-garbagee:\vue3-ts\src\utils\verify\index.ts
 */

import * as Validates from './validates';

/**
 * @description: 生成自定义校验函数
 * @param {String} key - Validates的key
 * @param {String} msg - 校验的提示信息
 * @return {Function} 返回校验后的回调
 */

export const formValidateGene = (key: string, msg: string): any => (_rule: any, value: any) => {
  if (!Validates[key](value)) {
    return Promise.reject(msg);
  }
  return Promise.resolve();
};
